Yahoo Finance stock price analysis

Apple Inc.

Grzegorz Chadysz, Konrad ArchiciƄski

29.05.2021


Introduction

This R Markdown report enables to analyze time series from Yahoo Finance of user’s choice. The report takes user input and creates tables, plots and tests based on that input and allows to thoroughly analyze different quotes and time spans without interfering with the code.

This version of report provides several tech and motor companies to choose from, however, should one want to analyze another, he/she should add the abbreviation and company’s full name to the parameter’s choice list and dictionary and the report would be good to go. Default time range spans back a thousand days from the day of running the report. Should the multiple choice for the quotes be left empty, then as default, all prices are included in the analysis. Last parameter determines the forecast period in days.


Data

Gathering of the time series data is performed via getSymbols function provided in quantmod package. More information about the package can be found here. Data used in this particular report is characterized by following parameters:

  • Company name: Apple Inc.
  • Company abbreviation: AAPL
  • Time span: 2018-09-02 - 2021-05-29
  • Quotes: None
  • Forecast: 0 days

Below you can see a glimpse of the first and last few observations of the data of your choice.

Most recent observations
Date AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Adjusted AAPL.Volume
2021-05-28 125.57 125.80 124.55 124.61 124.61 71 232 700
2021-05-27 126.44 127.64 125.08 125.28 125.28 94 625 600
2021-05-26 126.96 127.39 126.42 126.85 126.85 56 575 900
2021-05-25 127.82 128.32 126.32 126.90 126.90 72 009 500
2021-05-24 126.01 127.94 125.94 127.10 127.10 63 092 900
2021-05-21 127.82 128.00 125.21 125.43 125.43 79 209 300
Oldest observations
Date AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Adjusted AAPL.Volume
2018-09-11 54.5025 56.0750 54.1400 55.9625 54.29848 142 996 000
2018-09-10 55.2375 55.4625 54.1175 54.5825 52.95951 158 066 000
2018-09-07 55.4625 56.3425 55.1775 55.3250 53.67994 150 479 200
2018-09-06 56.5575 56.8375 55.3250 55.7750 54.11656 137 160 000
2018-09-05 57.2475 57.4175 56.2750 56.7175 55.03103 133 332 000
2018-09-04 57.1025 57.2950 56.6575 57.0900 55.39246 109 560 400

Descriptive statistics

General

Below you can find a handful of descriptive statistics regarding the columns specified during knitting. Maximum price recorded for Apple Inc. during 2018-09-02 - 2021-05-29 period was $145.09, while the minimum was $31.82.

Stats per variable
Variable Mean Std. Min 1st quartile Median 3rd quartile Max
AAPL.Open 79.06 32.36 35.99 51.07 67.50 115.23 143.60
AAPL.High 80.02 32.74 36.43 51.53 69.31 116.55 145.09
AAPL.Low 78.08 31.82 35.50 50.72 66.82 113.61 141.37
AAPL.Close 79.08 32.27 35.55 51.12 68.31 115.08 143.16
AAPL.Adjusted 78.32 32.56 34.61 50.12 67.67 114.52 142.70
AAPL.Volume 133 179 276.20 60 331 655.95 45 448 000.00 91 717 600.00 116 736 000.00 157 125 200.00 426 510 000.00

Log returns

This chapter provides insight on the log returns of selected prices. Log returns are more widely used in finance than simple returns for a number of reasons, one being that prices are assumed to be log-normally distributed. That is not always the case as can be seen on the graphs below. Nevertheless, this assumption results in logarithms of prices to be normally distributed. More information on this topic can be found here.

Each of the graphs below represents a histogram of log returns of certain price, as well as kernel density estimate (white line). It is plotted agains a normal distribution (red line) with mean and standard deviation calculated separately for each graph.

AAPL.Open

AAPL.High

AAPL.Low

AAPL.Close

AAPL.Adjusted


Plotting

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."


Stationarity analysis

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Trend

## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.0316  -0.7813   0.1243   0.7799   9.3996 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.0065912  0.1500865  -0.044  0.96498    
## z.lag.1     -1.1618669  0.0549135 -21.158  < 2e-16 ***
## tt           0.0003589  0.0003781   0.949  0.34294    
## z.diff.lag   0.1155851  0.0380447   3.038  0.00247 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.959 on 682 degrees of freedom
## Multiple R-squared:  0.5271, Adjusted R-squared:  0.525 
## F-statistic: 253.3 on 3 and 682 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.1581 149.2237 223.8355 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2  6.09  4.68  4.03
## phi3  8.27  6.25  5.34


According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -21.1581278 is smaller than tau3 5pct: -3.41.


Drift

## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.9871 -0.7769  0.0824  0.7793  9.4498 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.11679    0.07500   1.557  0.11989    
## z.lag.1     -1.15936    0.05485 -21.138  < 2e-16 ***
## z.diff.lag   0.11432    0.03802   3.007  0.00274 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.959 on 683 degrees of freedom
## Multiple R-squared:  0.5264, Adjusted R-squared:  0.5251 
## F-statistic: 379.6 on 2 and 683 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.1385 223.4177 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1  6.43  4.59  3.78


According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -21.1384808 is smaller than tau3 5pct: -2.86.


None

## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.9020 -0.6647  0.1942  0.8967  9.5563 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -1.15303    0.05475 -21.059  < 2e-16 ***
## z.diff.lag  0.11114    0.03800   2.924  0.00356 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.961 on 684 degrees of freedom
## Multiple R-squared:  0.5248, Adjusted R-squared:  0.5234 
## F-statistic: 377.6 on 2 and 684 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -21.0591 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62


According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -21.059126 is smaller than tau3 5pct: -1.95.


Forecasting?

ARIMA?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.